$(function(){
	PayMentRecordApp.init();
});

var PayMentRecordApp = function(){

	return {
		init :function(){
			//加载内容
			PayMentRecordApp.loadGrid();
			//绑定时间
			PayMentRecordApp.bindEvent();
		},
		bindEvent:function(){
			
			$("#submit").on("click",function(){
				PayMentRecordApp.reload();
			});
			$("#reset").on("click",function(){
				$("#companyName").val("");
				 $("#date_from").val("");
			        $("#date_to").val("");
			});
			
			 $( "#date_from" ).datepicker({
			        showOtherMonths: true,
			        selectOtherMonths: false,
			        format: "yyyy-mm-dd"
			    });
			    $( "#date_to" ).datepicker({
			        showOtherMonths: true,
			        selectOtherMonths: false,
			        format: "yyyy-mm-dd"
			    });
		},
		loadGrid:function(){
		
		
			gui.widgets.BootStrap.loadGrid({
				gridSelector:"#grid-table",
				pagerSelector:"#grid-pager",
				postData:{
					
					"buyyerName":function(){
						return $("#companyName").val();
					},
					"ulGmtCreate":function(){
						return $("#date_from").val();
					},
					"flGmtCreate":function(){
						return $("#date_to").val();
					},
					
				},
				jsonReader : {  
					root: "data.rows",
					records: "data.total",  
			        repeatitems : false,
			        total: function (obj) {
                        return  Math.ceil(obj.total /jQuery("#grid-table").getGridParam("rowNum"));
                    },
				} , 
				datatype: 'json',
				url:$('#APP_ROOT_PATH').val() + 'deposit_user/page_data',
				colNames:['时间','流水号','公司名称','收费金额(元)','三方支付单号'],
				colModel:[
					{name:'gmtCreate',index:'gmtCreate',sortable:false,width:100},
					{name:'orderNo',index:'orderNo',sortable:false,width:80},
					{name:'buyyerName',index:'buyyerName',sortable:false,width:100},
					{name:'amount',index:'amount',sortable:false,width:50},
					{name:'depositNo',index:'depositNo',sortable:false,width:100},
					
				],
				shrinkToFit:false,
				autoScroll: true,
				caption: "收费记录",
				rowList:[10,20,30],
				multiselect: true,
				prmNames:{
					page:"pageNum",
					rows:"pageSize", 
					sort: "sortField",
					order: "sortOrder", 
					search:"_search" 
				}
			});
		},
	
		reload:function(){
//			console.log($("#companyName").val());
//			console.log($("#date_from").val());
//			console.log($("#date_to").val());
//			return false;
			jQuery("#grid-table").jqGrid('setGridParam',{page:1}).trigger("reloadGrid");  
		}
		
	}
}();